package com.usian.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.user.dtos.AuthDto;
import com.usian.model.user.pojos.ApUserRealname;
import com.usian.user.mapper.ApUserRealnameMapper;
import com.usian.user.service.ApUserRealnameService;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApUserRealnameServiceImpl implements ApUserRealnameService {
    @Autowired
    private ApUserRealnameMapper apUserRealnameMapper;

    @Override
    public ResponseResult loadListByStatus(AuthDto authDto) {
        if (authDto == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
//        检查参数
        authDto.checkParam();
        QueryWrapper<ApUserRealname> qw = new QueryWrapper<>();
        if (authDto.getStatus() != null){
            qw.eq("status",authDto.getStatus());
        }
        Page page = new Page<>(authDto.getPage(), authDto.getSize());
        Page page1 = apUserRealnameMapper.selectPage(page, qw);
        PageResponseResult responseResult = new PageResponseResult(authDto.getPage(), authDto.getSize(), (int) page.getTotal());
        responseResult.setData(page1.getRecords());
        return responseResult;
    }

}
